/*
 * UnitMap.h
 *
 *  Created on: 2013-1-19
 *      Author: heqiu
 */

#ifndef UNITMAP_H_
#define UNITMAP_H_
#include "GuudPoint.h"
#include "GuudFloatPoint.h"
#include "GuudBitSet.h"
#include "UnitBuilding.h"

namespace guud {
class UnitMap {
public:
	UnitMap();
	~UnitMap();
	//初始化大小 (短轴，长轴， (s,0)(l,0)(0,s)(0,l) 四点中的矩形为地图大小
	bool init(uint32_t uiShort, uint32_t uiLong);
	//获取四个顶点的坐标
	void getPeak(GuudPoint & stA, GuudPoint & stB, GuudPoint & stC,
			GuudPoint & stD);
	//判断点是否在地图内部
	bool bPointIn(GuudPoint & p);
	//循环所有的地图内部坐标
	void cycle(void (*func)(uint32_t, uint32_t));
	//地图转换成屏幕坐标
	void transformToScreen(GuudPoint stMap, GuudPoint & stScreen);
	void transformToScreen(GuudFloatPoint stMap, GuudFloatPoint & stScreen);
	//屏幕转换成地图坐标
	void transformToMap(GuudPoint stScreen, GuudPoint & stMap);
	void transformToMap(GuudFloatPoint stScreen, GuudFloatPoint & stMap);

	//获取坐标位置建筑
	uint32_t getBuilding(uint32_t uiX, uint32_t uiY);
	//检测是否可以建筑
	bool testBuilding(UnitBuilding & stNode);
	//在地图上建筑
	bool setBuilding(UnitBuilding & stNode);
	//打印建筑坐标
	void printBuilding();
private:
	uint32_t m_uiShort;	//最短轴
	uint32_t m_uiLong;	//最长轴

	GuudPoint m_stA;	//四个顶点
	GuudPoint m_stB;
	GuudPoint m_stC;
	GuudPoint m_stD;

	uint32_t * m_pBuilding;
	GuudBitSet m_bitSetWay;
};

}

#endif /* UNITMAP_H_ */
